Filter hook 'rest_{$this->taxonomy}_collection_params'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php at line 1225

View Source

rest_{$this->taxonomy}_collection_params

Filter Hook
Description
Filters collection parameters for the terms controller. The dynamic part of the filter `$this->taxonomy` refers to the taxonomy slug for the controller. This filter registers the collection parameter, but does not map the collection parameter to an internal WP_Term_Query parameter. Use the `rest_{$this->taxonomy}_query` filter to set WP_Term_Query parameters.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php View on GitHub
Hook Type Filter
Line Number 1225

Hook Parameters

Type Name Description
array $query_params JSON Schema-formatted collection parameters.
WP_Taxonomy $taxonomy Taxonomy object.

Usage Examples

Basic Usage
<?php
// Hook into rest_{$this->taxonomy}_collection_params
add_filter('rest_{$this->taxonomy}_collection_params', 'my_custom_filter', 10, 2);

function my_custom_filter($query_params, $taxonomy) {
    // Your custom filtering logic here
    return $query_params;
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php:1225 - How this hook is used in WordPress core
<?php
1220  		 * @since 4.7.0
1221  		 *
1222  		 * @param array       $query_params JSON Schema-formatted collection parameters.
1223  		 * @param WP_Taxonomy $taxonomy     Taxonomy object.
1224  		 */
1225  		return apply_filters( "rest_{$this->taxonomy}_collection_params", $query_params, $taxonomy );
1226  	}
1227  
1228  	/**
1229  	 * Checks that the taxonomy is valid.
1230  	 *

PHP Documentation

<?php
/**
		 * Filters collection parameters for the terms controller.
		 *
		 * The dynamic part of the filter `$this->taxonomy` refers to the taxonomy
		 * slug for the controller.
		 *
		 * This filter registers the collection parameter, but does not map the
		 * collection parameter to an internal WP_Term_Query parameter.  Use the
		 * `rest_{$this->taxonomy}_query` filter to set WP_Term_Query parameters.
		 *
		 * @since 4.7.0
		 *
		 * @param array       $query_params JSON Schema-formatted collection parameters.
		 * @param WP_Taxonomy $taxonomy     Taxonomy object.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
Related Hooks

Related hooks will be displayed here in future updates.